package com.yelin.taketitle

import android.os.Bundle
import android.util.Log
import android.webkit.ConsoleMessage
import android.webkit.WebChromeClient
import androidx.appcompat.app.AppCompatActivity
import com.github.lzyzsd.jsbridge.DefaultHandler
import kotlinx.android.synthetic.main.activity_web_view.*

class WebViewActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_web_view)

        webView.setDefaultHandler(DefaultHandler())
        webView.webChromeClient = object : WebChromeClient() {
            override fun onConsoleMessage(consoleMessage: ConsoleMessage): Boolean {
                Log.d("jsBridge log", consoleMessage.message())
                return super.onConsoleMessage(consoleMessage)
            }
        }
        webView.loadUrl("https://www.baidu.com/")
    }
}
